m=z=0 for s in[*open(0)][1:]:c,x=s.split();m=max(m,z:=z+int(x)*(2*(c>'G')-1)) print(m)